<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page import="com.reserv.util.TimestampUtil"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:requestEncoding value="utf-8" />
<div class="col-xs-12" id="listDiv">
	<div>
		<ol class="breadcrumb">
			<li><a href="/Reservation/main/index.res">홈</a></li>
			<c:if test="${ param.type == 'gym' }">
				<li class="active">체육시설</li>
			</c:if>
			<c:if test="${ param.type == 'pub' }">
				<li class="active">시설대관</li>
			</c:if>
		</ol>
	</div>
	<c:if test="${ param.type == 'gym' }">
		<div class="page-header">
			<h3>체육시설</h3>
			<small>조회하고자하는 체육시설을 누르면, 해당 시설의 정보를 조회하실 수 있습니다.</small>
		</div>
	</c:if>
	<c:if test="${ param.type == 'pub' }">
		<div class="page-header">
			<h3>시설대관</h3>
			<small>조회하고자하는 공공시설을 누르면, 해당 시설의 정보를 조회하실 수 있습니다.</small>
		</div>
	</c:if>
	<div id="srchDiv">
		<form id="svSrchForm">
			<input type="hidden" name="type" value="${ param.type }" />
			<input type="hidden" name="" value="" />
			<input type="hidden" name="" value="" />
			<input type="hidden" name="" value="" />
			<input type="hidden" name="" value="" />
			<input type="hidden" name="" value="" />
			<div>
				<label>접수기간&nbsp;:&nbsp;</label>
				<div class="input-group input-group-sm">
					<input type="text" class="form-control datepicker" name="rtsDate" value="${ rtsDate }" />
					<span class="input-group-addon"> <span
						class="glyphicon glyphicon-calendar"></span>
					</span>
				</div>
				<label>&nbsp;~&nbsp;</label>
				<div class="input-group input-group-sm">
					<input type="text" class="form-control datepicker" name="rteDate" value="${ rteDate }" />
					<span class="input-group-addon"> <span
						class="glyphicon glyphicon-calendar"></span>
					</span>
				</div>
				<label>&nbsp;&nbsp;서비스 지역&nbsp;:&nbsp;</label> <select name="local"
					class="form-control input-sm">
					<c:if test="${ local eq '전체' }">
						<option selected="selected">전체</option>
					</c:if>
					<c:if test="${ local ne '전체' }">
						<option>전체</option>
					</c:if>
					<c:forEach var="selectLocal" items="${ sLocalList }">
						<c:if test="${ selectLocal eq local }">
							<option selected>${ selectLocal }</option>
						</c:if>
						<c:if test="${ selectLocal ne local }">
							<option>${ selectLocal }</option>
						</c:if>
					</c:forEach>
				</select> <label>&nbsp;&nbsp;분류별&nbsp;:&nbsp;</label> <select name="kind"
					class="form-control input-sm">
					<c:if test="${ kind eq '전체' }">
						<option selected="selected">전체</option>
					</c:if>
					<c:if test="${ kind ne '전체' }">
						<option>전체</option>
					</c:if>
					<c:forEach var="selectKind" items="${ sKindList }">
						<c:if test="${ selectKind eq kind }">
							<option selected="selected">${ selectKind }</option>
						</c:if>
						<c:if test="${ selectKind ne kind }">
							<option>${ selectKind }</option>
						</c:if>
					</c:forEach>
				</select>
				<button class="btn btn-default" type="button" id="svsBtn">검색</button>
			</div>
			<div>
				<label>이용기간&nbsp;:&nbsp;</label>
				<div class="input-group input-group-sm">
					<input type="text" class="form-control datepicker" name="rsDate" value="${ rsDate }" />
					<span class="input-group-addon"> <span
						class="glyphicon glyphicon-calendar"></span>
					</span>
				</div>
				<label>&nbsp;~&nbsp;</label>
				<div class="input-group input-group-sm last">
					<input type="text" class="form-control datepicker" name="reDate" value="${ reDate }" />
					<span class="input-group-addon"> <span
						class="glyphicon glyphicon-calendar"></span>
					</span>
				</div>
			</div>
		</form>
	</div>
	<div>
		<c:if test="${ listCount <= 0 }">
			<p>등록된 예약 시설물이 없습니다.</p>
		</c:if>
		<c:if test="${ listCount > 0 }">
			<table class="table" id="serviceTable">
				<c:forEach var="service" items="${ serviceList }">
					<tr>
						<td>
							<div class="row">
								<div class="col-xs-3">
									<div class="thumbnail">
										<a href="view.res?sno=${ service.sno }"> <img
											src="../img/fImg/${ service.img }.jpg"
											alt="${ service.title }" />
										</a>
									</div>
								</div>
								<div class="col-xs-9">
									<span>${ service.type == "gym" ? "체육시설" : "시설대관" } [ ${ service.kind }
										] | </span> <a href="view.res?sno=${ service.sno }" class="title">
										<strong>${ service.title }</strong> <c:if
											test="${ service.stat eq 0 }">
											<span class="label label-primary">접수중</span>
										</c:if> <c:if test="${ service.stat eq 1 }">
											<span class="label label-danger">접수마감</span>
										</c:if> <c:if test="${ service.stat eq 2 }">
											<span class="label label-warning">점검중</span>
										</c:if>
									</a>
									<p class="detailHeader">
										<strong>${ service.local }(${ service.phone })</strong>
									</p>
									<div class="info">
										<p>이용료 : ${ service.fee > 0 ? '유료' : '무료' }</p>
										<p>접수기간 : ${ tsu.dropSec(service.rtsDate) } ~ ${ tsu.dropSec(service.rteDate) }</p>
										<p>취소기간 : 이용일로부터 ${ service.rcDate }일 전까지</p>
										<p>이용기간 : ${ tsu.dropSec(service.rsDate) } ~ ${ tsu.dropSec(service.reDate) }</p>
									</div>
								</div>
								<div class="col-xs-10 detail">${ service.detail }</div>
								<div class="col-xs-2" id="goToDetail">
									<ul class="pager">
										<li class="next"><a href="view.res?sno=${ service.sno }">상세보기
												→</a></li>
									</ul>
								</div>
							</div>
						</td>
					</tr>
				</c:forEach>
			</table>
			<div class="listPage" style="text-align: center">
				<ul class="pagination">
					<c:if test="${ startPage > PAGE_GROUP }">
						<li><a
							href="list.res?type=${ param.type }&pageNum=${ startPage - PAGE_GROUP }&rtsDate=${ rtsDate }&rteDate=${ rteDate }&rsDate=${ rsDate }&reDate=${ reDate }&kind=${ kind }&local=${ local }"">«</a></li>
					</c:if>
					<c:if test="${ currentPage eq PAGE_GROUP }">
						<li class="disabled"><a href="#">«</a></li>
					</c:if>

					<c:forEach var="i" begin="${ startPage }" end="${ endPage }">
						<c:if test="${ i == currentPage }">
							<li class="active"><a>${ i }</a></li>
						</c:if>
						<c:if test="${ i != currentPage }">
							<li><a href="list.res?type=${ param.type }&pageNum=${ i }&rtsDate=${ rtsDate }&rteDate=${ rteDate }&rsDate=${ rsDate }&reDate=${ reDate }&kind=${ kind }&local=${ local }">${ i }</a></li>
						</c:if>
					</c:forEach>

					<c:if test="${ endPage < pageCount }">
						<li><a
							href="list.res?type=${ param.type }&pageNum=${ startPage + PAGE_GROUP }&rtsDate=${ rtsDate }&rteDate=${ rteDate }&rsDate=${ rsDate }&reDate=${ reDate }&kind=${ kind }&local=${ local }"">»</a></li>
					</c:if>
					<c:if test="${ currentPage eq pageCount }">
						<li class="disabled"><a href="#">»</a></li>
					</c:if>
				</ul>
			</div>
		</c:if>
	</div>
</div>
<script>
	$(".datepicker").datepicker({
		format : "yyyy-mm-dd",
		language : "kr",
		orientation : "top left",
		autoclose : true,
		todayHighlight : true
	});
	$("#svsBtn").click(
			function() {
				$("#svSrchForm").attr("method", "post")
				.attr("action", "/Reservation/reserv/list.res").submit();
			});
</script>